package com.future.hedongjun.mine.order;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.future.baselib.activity.BaseListFragment;
import com.future.hedongjun.common.MyApp;
import com.future.hedongjun.mall.bean.OrderDetail;
import com.future.hedongjun.mine.adapter.ClassOrderAdapter;
import com.future.hedongjun.mine.adapter.OrderAdapter;
import com.future.hedongjun.mine.bean.ClassOrderItem;
import com.future.hedongjun.mine.bean.DeliveryAddressBean;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClassOrderListFragment extends BaseListFragment {

    public ClassOrderListFragment() {
        // Required empty public constructor
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    protected void initView(View view, @Nullable Bundle savedInstanceState) {

    }

    @Override
    protected BaseQuickAdapter getAdapter() {
        return new ClassOrderAdapter(null);
    }

    private List<ClassOrderItem> initTestData() {
        List<ClassOrderItem> data = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            ClassOrderItem orderItem = new ClassOrderItem();
            orderItem.setStatus(i+1);
            orderItem.setName("我是一个粉刷家");
            orderItem.setOrder_num("123456");
            orderItem.setAmount(100);
            orderItem.setDiscount_price(10);
            orderItem.setLogo_img("");
            orderItem.setPay_type(1);
            orderItem.setPrice(110);
            data.add(orderItem);
        }
        return data;
    }

    @Override
    protected Type getTypeToken() {
        return new TypeToken<List<ClassOrderItem>>(){}.getType();
    }

    @Override
    protected TreeMap<String, String> getRequestParams() {
        TreeMap<String, String> map = new TreeMap<>();
        map.put("apiCode","_myclassindent_001");
        map.put("userToken",MyApp.getInstance().getUserToken());
        return map;
    }

    @Override
    protected String getPath() {
        return null;
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        Bundle bundle = new Bundle();
        bundle.putString("id", ((ClassOrderAdapter) adapter).getData().get(position).getId());
        bundle.putSerializable("data", ((ClassOrderAdapter) adapter).getData().get(position));
        startActivity(ClassOrderDetailActivity.class, bundle);
    }


}
